package cn.kgc.springcloud.controller;

import cn.kgc.springcloud.entity.Order;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 课工场
 * @Version: v1.0  2023/2/17
 * @Description:
 */
@RequestMapping("order")
@RestController
public class OrderController {

    @Value("${server.port}")
    private Integer port;

    @RequestMapping("test1")
    public String test01(){
        return "OrderService ok  --> " +port;
    }


    @RequestMapping("test2")
    public String test02(@RequestParam("id") Integer id){

        System.out.println("查询订单成功，订单的编号 = "+id);

        return "OrderService ok  --> " +port;
    }


    @RequestMapping("test3/{id}")
    public String test03(@PathVariable("id") Integer id){

        System.out.println("保存订单成功，订单的编号 = "+id);

        return "OrderService ok  --> " +port;
    }


    @RequestMapping("test4") // json  order  @RequestBody
    public String test04(@RequestBody Order order){
        System.out.println("order = " + order);

        return "OrderService ok  --> " +port;
    }

    @RequestMapping("test5")
    public Order test05(@RequestParam("id") Integer id){
        Order order = new Order();
        order.setId(id);
        order.setName("bb");
        return order;
    }


    @RequestMapping("test6")
    public String test06(String color){
        return "OrderService ok  --> color = "+ color + "port = "+port;
    }


}
